package com.github.manx98.okdownloader.utils;

/**
 * 封装下载块以及下载链接
 *
 * @author : manx98
 * @date : 2021/5/24
 */
public class DownloadBlockInfoWithLink {
    private final DownloadLink link;
    private final DownloadBlockInfo downloadBlockInfo;

    /**
     * 下载任务块
     *
     * @param downloadBlockInfo 下载任务块
     * @param link              下载链接
     */
    protected DownloadBlockInfoWithLink(DownloadBlockInfo downloadBlockInfo, DownloadLink link) {
        this.downloadBlockInfo = downloadBlockInfo;
        this.link = link;
    }

    /**
     * 下载连接
     *
     * @return 下载连接对象
     */
    public DownloadLink getLink() {
        return link;
    }

    protected DownloadBlockInfo getDownloadBlockProgressInfo() {
        return downloadBlockInfo;
    }

    /**
     * 获取状态码
     *
     * @return 状态码
     */
    public short getCode() {
        return downloadBlockInfo.code;
    }

    /**
     * 设置状态码
     *
     * @param code 状态码
     */
    protected void setCode(short code) {
        this.downloadBlockInfo.code = code;
    }

    /**
     * 获取结束下标
     *
     * @return 结束下标
     */
    public long getEnd() {
        return this.downloadBlockInfo.end;
    }

    /**
     * 获取起始下标
     *
     * @return 起始下标
     */
    public long getStart() {
        return this.downloadBlockInfo.getStart();
    }
}
